package com.thinkingcoder.tcdfs;

import org.apache.rocketmq.spring.autoconfigure.RocketMQAutoConfiguration;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

import com.thinkingcoder.tcdfs.properties.TcDfsProperties;
import com.thinkingcoder.tcdfs.util.FileUtils;

@SpringBootApplication
@EnableConfigurationProperties(TcDfsProperties.class)
@Import({RocketMQAutoConfiguration.class})
public class TcDfsApplication {

    public static void main(String[] args) {
        SpringApplication.run(TcDfsApplication.class, args);
    }

    // 1. 基于文件存储的分布式文件系统
    // 2. 块存储 ==> 最常见，效率最高 ==> 改造成这个。
    // 3. 对象存储
    @Value("${tcdfs.path}")
    private String uploadPath;

    @Bean
    ApplicationRunner tcDfsRootUploadDirInit() {
        return args -> {
            FileUtils.init(uploadPath);
            System.out.println("TC-DFS started on rootPath: " + uploadPath);
        };
    }
}
